<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
  <title>任务中心--接收的任务</title>

  <!-- Set render engine for 360 browser -->
  <meta name="renderer" content="webkit">

  <!-- No Baidu Siteapp-->
  <meta http-equiv="Cache-Control" content="no-siteapp"/>

  <link rel="icon" type="image/png" href="images/bee.png">

  <!-- Add to homescreen for Chrome on Android -->
  <meta name="mobile-web-app-capable" content="yes">
  <!-- <link rel="icon" sizes="192x192" href="assets/i/app-icon72x72@2x.png"> -->

  <!-- Add to homescreen for Safari on iOS -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
  <!-- <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png"> -->

  <!-- Tile icon for Win8 (144x144 + tile color) -->
  <meta name="msapplication-TileImage" content="assets/i/app-icon72x72@2x.png">
  <meta name="msapplication-TileColor" content="#0e90d2">

  <link rel="stylesheet" href="assets/css/amazeui.min.css">
  <link rel="stylesheet" href="assets/css/app.css">
</head>
<body style="background: url(images/bg1.png) no-repeat;background-size: cover; background-attachment:fixed;">
  
  <!--在这里编写你的代码-->
  <!-- 页头 -->
  <header data-am-widget="header"
  class="am-header am-header-default" style="background-color: #F6B541;">
  <div class="am-header-left am-header-nav">
    <!-- <a href="#left-link">
        <span class="am-header-nav-title">
          首页
        </span>
    
          <i class="am-header-icon am-icon-home"></i>
    </a> -->
    <ul>
      <a href="yfpage.html">
        <li style="display: flex;flex-direction: row;width: 200px;">
            <img src="images/shouye.png" alt="管理员联系方式" style="width: 150px; height: 22px;margin-top: 10px; margin-left: -10%;">
            <!-- <p style="color: #000; margin-top: 0;font-size: 16px;">小蜜蜂图片收集网</p> -->
        </li>
      </a>
    </ul>
    </div>
    
  
    <div class="am-header-right am-header-nav">
      <a href="jobfachu.html">
        <div style="display: flex;flex-direction: column;margin-left: -40px;">
          <img src="images/rw.png" alt="管理员联系方式" style="width: 30px; height: 25px;">
          <span style="color: black; font-weight: 700; font-size: 12px;margin-left: -48px; margin-top: -14px;" onclick="rw()">任务</span>
        </div>
      </a>
      <a href="personal.html">
        <div style="display: flex;flex-direction: column;margin-left: -10px;">
          <img src="images/xr.png" alt="管理员联系方式" style="width: 25px; height: 20px;">
          <span style="color: black; font-weight: 700; font-size: 12px;margin-left: -18px; margin-top: -14px;" onclick="per()">我的</span>
        </div>
      </a>
    </div>

  </header>
  <div class="am-container" style="background-color: rgba(241, 246, 249, 0.65); margin-top: 60px; 
  box-shadow: 5px 5px 5px rgba(0,0,0,0.1); 
 border-radius: 5px; ">

     <div class="am-g" style="margin-top: 5vh;">
       <div class="am-u-sm-5 " style="margin-left: 12px; ">
         <div class="am-btn-group" >
           <button type="button" class="am-btn am-btn-primary am-round" style="background-color: #fff; color: #75C3B6;" onclick="jobfachu()">发出的任务</button>
           <button type="button" class="am-btn am-btn-primary am-round" style="background-color: #75C3B6;">接收的任务</button>
         </div>
       </div>
       <!-- <div class="am-u-sm-2" style="margin-right: -1.8vw; ">
        <button type="button" class="am-btn am-btn-primary am-round" style="background-color: #75C3B6;">派发任务</button>
       </div> -->
     </div>

     

     <ul class="tasklist" style="list-style: none; padding: 0;">
          
  
    </ul>
    <div id="tasklist">
      <div data-am-widget="list_news" class="am-list-news am-list-news-default" style="margin-top: 1vh; border-bottom: none; " v-for="(item ,i) in arr">
        <div class="am-list-news-bd">
        <ul class="am-list">
          <li 
             class="am-g am-list-item-dated" style="border-color: rgba(255,255,255, 0.65); background-color: rgba(255,255,255, 0.65);">
            <div class="am-g">
              <div class="am-u-sm-2">
                <img src="images/ss.png" style="width: 30px; height: 30px; margin-top: 2vh;margin-bottom: 2vh;">
            <span style="font-size:large; font-family: SimHei; font-weight: 700;">任务编号：</span>
              </div>
              <div class="am-u-sm-2 am-u-end" id="kkk">
                <label style="margin-top: 2vh;margin-bottom: 2vh;">{{item.tasknum}}</label>
                </div>
            </div>
            </li>
            <li class="am-g am-list-item-dated" style="border-color: rgba(255,255,255, 0.65); background-color: rgba(255,255,255, 0.65);">
              <div class="am-g">
                <div class="am-u-sm-2" >  <!-- style="margin-left: -161px;" -->
                  <img src="images/bq.png" style="width: 30px; height: 30px; margin-top: 2vh;margin-bottom: 2vh;">
                  <span style="font-size:large; font-family: SimHei; font-weight: 700;">标签：</span>
                </div>
                <div class="am-u-sm-2 am-u-end">
                  <label style="margin-top: 2vh;margin-bottom: 2vh;">{{item.tag}}</label>
                </div>
              </div>
            </li>
            <li class="am-g am-list-item-dated" style="border-color: rgba(255,255,255, 0.65); background-color: rgba(255,255,255, 0.65);">
        <div class="am-g">
          <div class="am-u-sm-2" >
            <img src="images/sj.png" style="width: 30px; height: 30px; margin-top: 2vh;margin-bottom: 2vh;">
        <span style="font-size:large; font-family: SimHei; font-weight: 700;">起止日期：</span>
          </div>
          <div class="am-u-sm-3" >
              <div class="am-form-group am-form-icon">
                <i class="am-icon-calendar"></i>
                <input type="text" class="am-form-field" placeholder="开始日期" v-bind:value="item.begintime" style=" margin-top: 2vh;margin-bottom: 2vh;" readonly>
              </div>
          </div>
          <div class="am-u-sm-3 ">
            <div class="am-form-group am-form-icon">
              <i class="am-icon-calendar"></i>
              <input type="text" class="am-form-field" placeholder="结束日期" v-bind:value="item.endtime" style=" margin-top: 2vh;margin-bottom: 2vh;" readonly>
            </div>
          </div>
          <div class="am-u-sm-3 " style="text-align: center;">
            <button type="button" class="am-btn am-btn-danger am-round" v-bind:id="item.bianhao" style="background-color: #75C3B6; text-align: center;
        width: 150px; height: 50px; margin-top: 2vh;margin-bottom: 2vh; border-radius: 10px;border: none; color: #000;
         font-family: SimHei;font-size: x-large;outline: 0;" v-on:click="lookdetail(i)">
            查看进度</button>
          </div>
        </div>
        <li class="am-g am-list-item-dated" style="border-color: rgba(255,255,255, 0.65); background-color: rgba(255,255,255, 0.65);">
          <div class="am-g">
            <div class="am-u-sm-2">
              <img src="images/sx.png" style="width: 30px; height: 30px; margin-top: 2vh;margin-bottom: 2vh;">
              <span style="font-size:large; font-family: SimHei; font-weight: 700;">需求描述：</span>
            </div>
            <div class="am-u-sm-2 am-u-end">
              <textarea class="" rows="4" id="doc-ta-1" style="width: 35vw; border-radius: 10px;margin-bottom: 2vh;" readonly>{{item.taskinfo}}</textarea>
            </div>
          </div>
      </li>
        </ul>
        </div>
          </div>
  </div>
  <div class="none" style="align-items: center; text-align: center;opacity: 0.8;display: flex;flex-direction: column; "></div>

  <div data-am-widget="gotop" class="am-gotop am-gotop-default" style="text-align: center; margin-bottom: 2vh;">
    <a href="#top" title="首页" style="background-color: #fff;"onclick="firstPage()">
      <input type="button" value="首页" style="background-color: #fff; color:#000;border: none; " >
  </a>
  <a href="#top" title="上一页" style="background-color: #fff;"onclick="prevPage()">
    <input type="button" value="上一页" style="background-color: #fff; color:#000; border: none;" >
</a>
  <a href="#top" title="下一页" style="background-color: #fff;"onclick="nextPage()">
    <input type="button" value="下一页" style="background-color: #fff; color:#000;border: none; ">
</a>
<a href="#top" title="尾页" style="background-color: #fff;"onclick="lastPage()">
  <input type="button" value="尾页" style="background-color: #fff; color:#000; border: none;" >
</a>
  </div>
  </div>
  

<!-- 页脚 -->
<footer data-am-widget="footer"
class="am-footer am-footer-default"
 data-am-footer="{  }" style="background-color: rgba(255,255,255,0) ;">
<div class="am-footer-switch">
<span class="am-footer-ysp" data-rel="mobile"
data-am-modal="{target: '#am-switch-mode'}">
云适配版
</span>
<span class="am-footer-divider"> | </span>
<a id="godesktop" data-rel="desktop" class="am-footer-desktop" href="javascript:">
电脑版
</a>
</div>
<div class="am-footer-miscs ">

<p>由 <a href="http://www.yunshipei.com/" title="诺亚方舟"
                                      target="_blank">诺亚方舟</a>
  提供技术支持</p>
<p>CopyRight©2014  AllMobilize Inc.</p>
<p>京ICP备13033158</p>
<br>
<p>NaN团队--小蜜蜂图片收集网</p>
</div>
</footer>

<div id="am-footer-modal"
class="am-modal am-modal-no-btn am-switch-mode-m am-switch-mode-m-default">
<div class="am-modal-dialog">
<div class="am-modal-hd am-modal-footer-hd">
<a href="javascript:void(0)" data-dismiss="modal" class="am-close am-close-spin " data-am-modal-close>&times;</a>
</div>
<div class="am-modal-bd">
您正在浏览的是

<span class="am-switch-mode-owner">
  云适配
</span>

<span class="am-switch-mode-slogan">
    为您当前手机订制的移动网站。
</span>
</div>
</div>
</div>



<!--[if (gte IE 9)|!(IE)]><!-->
<!-- <script src="assets/js/jquery.min.js"></script> -->
<!--<![endif]-->
<!--[if lte IE 8 ]-->
<script src="http://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="assets/js/amazeui.ie8polyfill.min.js"></script>
<!--[endif]-->
<script src="assets/js/amazeui.min.js"></script>
<script src="../../routes/vue.js"></script>   <!--用到Vue记得这一行-->>
<script>
   $none=$('.none');
  var vm = new Vue({
        el: '#tasklist',
        data: {
          arr:[],//当前页面内容
          arr1:[],//计算总页数
      totalPage: 1, // 统共页数，默认为1
			currentPage: 1, //当前页数 ，默认为1
			pageSize: 3, // 每页显示数量
      headPage: 1,
        },
        methods: {
            details: function(a) {
              vm.arr.push(a)
            },
            details1: function(a) {
              console.log(a)
              vm.arr1.push(a)
              console.log(vm.arr1.length)
                vm.totalPage=Math.ceil(vm.arr1.length / vm.pageSize);
                vm.currentPage =1
            }
        }
    })

    const xhr=new XMLHttpRequest();
        xhr.open('POST','http://localhost/jobjieshou');
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.send('username='+window.sessionStorage.getItem('username'));
        console.log('555')
        // const username=window.sessionStorage.getItem('username');
        xhr.onreadystatechange=function(){
            // 判断
            if(xhr.readyState == 4 && xhr.status == 200)
                {
                    // 处理服务端返回的结果
                    console.log('666')
                    console.log(xhr.responseText)
                    var theNew = JSON.parse(xhr.responseText).b
                    console.log(theNew)
                    if(xhr.responseText.indexOf(true)+1)
                    {
                      console.log('1111')
                      vm.arr = []
                      vm.arr1=[]
                      if(theNew.length>=3){
                        console.log('shiung')
                        for(var i = 0;i<3;i++)
                      {
                        console.log('sognn')
                        vm.details(theNew[i][0])
                      }
                      }
                      else if(theNew.length<3&&theNew.length>0)
                      {
                        console.log('jjjjjjjjjjj')
                        console.log('小于3')
                        console.log(theNew.length)
                        console.log('jaoengoih')
                        for(var i = 0;i<theNew.length;i++)
                      {
                        vm.details(theNew[i][0])
                      }
                      }
                      else{
                        console.log('为0')
                      $(function(){
                        $none.append(' <img src="images/loading.png" style="margin-top: 5vh;width:180px;height:180px;">\
                        <label style="margin-top: 5vh;margin-bottom: 5vh; ">您还没有接收任务...</label>')
                    })

                      }
                      console.log('2222')
                      console.log(theNew.length)
                      for(var i = 0;i<theNew.length;i++)
                      {
                        vm.details1(theNew[i][0])
                      }
                      console.log(vm.arr)
                    }
                    
                      console.log(vm.arr)                      
                  }
              }
//上一页
function prevPage() {
    if (vm.currentPage == 1) {
                  console.log('3')  
                  return false; 
                } else {
                  console.log('7')
                    vm.currentPage--;
                    let begin = (vm.currentPage - 1) * vm.pageSize;
			              let end = vm.currentPage * vm.pageSize;
                    vm.arr = []
                    if(end<vm.arr1.length){
                      for(var i = begin;i<begin+3;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                    }
                    else{
                      for(var i = begin;i<vm.arr1.length;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                    }
                }
            }
            // 下一页
  function  nextPage() {
    if (vm.currentPage == vm.totalPage) {
                  console.log('3')  
                  console.log(vm.totalPage)
                  return false;
                   
                } else {
                  console.log()
                  console.log('7')
                    vm.currentPage++;
                    let begin = (vm.currentPage - 1) * vm.pageSize;
			              let end = vm.currentPage * vm.pageSize;
                    vm.arr = []
                    console.log('jjjjj')

                    if(end<vm.arr1.length){
                      for(var i = begin;i<begin+3;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                      console.log('222')
                      console.log(vm.arr1.length)
                    }
                    else{
                      for(var i = begin;i<vm.arr1.length;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                      console.log('333')
                      console.log(vm.arr1.length)
                    }
                }
                
            }
            //尾页
  function   lastPage() {
    if (vm.currentPage == vm.totalPage) {
                  console.log('3')  
                  return false;
                } else {
                  console.log('7')
                  vm.currentPage=vm.totalPage;
                  console.log('555')
                  console.log(vm.totalPage)
                    let begin = (vm.currentPage - 1) * vm.pageSize;
			              let end = vm.currentPage * vm.pageSize;
                    vm.arr = []
                    if(end<vm.arr1.length){
                      for(var i = begin;i<begin+3;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                    }
                    else{
                      for(var i = begin;i<vm.arr1.length;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                    }
                }     
            }
            //首页
  function    firstPage(){
    if (vm.currentPage ==1) {
                  console.log('3')  
                  return false;
                } else {
                    console.log('7')
                    vm.currentPage=  vm.headPage;
                    let begin = (vm.currentPage - 1) * vm.pageSize;
			              let end = vm.currentPage * vm.pageSize;
                    vm.arr = []
                    if(end<vm.arr1.length){
                      for(var i = begin;i<begin+3;i++)
                      {
                        vm.details(vm.arr1[i])
                      }

                    }
                    else{
                      for(var i = begin;i<vm.arr1.length;i++)
                      {
                        vm.details(vm.arr1[i])
                      }
                    }
                }
         }

  function jobfachu()
  {
    window.location.href='./jobfachu.html'
  }
  function yfpage()
  {
    window.location.href='./yfpage.html'
  }
  function lookdetail(a)
  {
    const id = vm.arr[a]['tasknum']
    const status = vm.arr[a]['status']
    console.log(id)
    sessionStorage.setItem('id',id)
    sessionStorage.setItem('status',status)
    window.location.href='./processjieshou.html?id='+id
    
  }
</script>
</body>
</html>